package com.bdqn.bookshop.controller.mall;

import com.bdqn.bookshop.entity.Notice;
import com.bdqn.bookshop.service.NoticeService;
import com.bdqn.bookshop.utils.Result;
import com.bdqn.bookshop.vo.NoticeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author : 罗若然[LUO_RUO_RAN]
 * @date : 2020-08-04 15:58
 **/
@Controller
@RequestMapping("/notice")
public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    @RequestMapping("/getNoticeCount")
    @ResponseBody
    public Result getNoticeCount(String date){
        return noticeService.getNoticeCount(date);
    }

    @RequestMapping("/getNoticePage")
    public String getNoticePage(NoticeVo noticeVo, String date, Model model){
        List<Notice> notices = noticeService.getNoticePage(noticeVo,date);
        model.addAttribute("noticeList",notices);
        return "mall/notice::noticeData";
    }
}
